// 导入Redux
import { useSelector, useDispatch } from "react-redux";
// 导入Store中的action方法
import {
  increment,
  decrement,
  incrementByAmount,
} from "../store/modules/CountStore";
// 导入声明文件
import type { RootState } from "../store";

const StoreExample = () => {
  // 获取store数据
  const { value } = useSelector((state: RootState) => state.counter);
  //   派发action
  const disPatch = useDispatch();
  return (
    <>
      <div>这是store数据:{value}</div>
      <button onClick={() => disPatch(increment())}>增加1</button>
      <button onClick={() => disPatch(decrement())}>减少1</button>
      <button onClick={() => disPatch(incrementByAmount(10))}>增加10</button>
    </>
  );
};

export default StoreExample;
